package com.ejlchina.tool.adapter.pageadapter

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.ejlchina.tool.fragment.viewpager.FullAndDistancePagerFragment

class FullAndDistancePagerAdapter(fragment: Fragment, private val dataList: MutableList<FullAndDistancePagerFragment>): FragmentStateAdapter(fragment) {

    private val pageIds= dataList.map { it.hashCode().toLong() }
    override fun getItemCount(): Int {
        return dataList.size
    }

    override fun createFragment(position: Int): Fragment {
        return dataList[position]
    }

    override fun getItemId(position: Int): Long {
        return dataList[position].hashCode().toLong()
    }

    override fun containsItem(itemId: Long): Boolean {
        return pageIds.contains(itemId)
    }
}